package com.mwh.yuantu.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mwh.yuantu.entity.HistoryInfoEntity;
import com.mwh.yuantu.parameter.HistoryInfoParameter;
import com.mwh.yuantu.parameter.HistoryInfoSearchParameter;
import com.mwh.yuantu.dto.HistoryInfoDTO;
import org.springframework.beans.BeanUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * (HistoryInfo)表服务接口
 *
 * @author maweihong
 * @since 2023-11-01 09:47:30
 */
@Service
@Slf4j
public class HistoryInfoService extends BaseService {



    /**
     * 保存用户的播放记录
     * @param historyInfo
     */
    public void save(HistoryInfoEntity historyInfo) {
        // 1.0 删除该记录
        iHistoryInfoDAO.delete(historyInfo);

        // 2.0 添加该记录
        historyInfo.setUpdateTime(new Date());
        iHistoryInfoDAO.insert(historyInfo);
    }

    /**
     * 获取用户最新的5条历史记录
     * @param userId 用户id
     * @return
     */
    public List<Map<String, Object>> listHistory5(String userId) {
        List<Map<String, Object>> list = iHistoryInfoDAO.listHistory5(userId);
        return list;
    }

    /**
     * 获取用户的历史记录列表
     * @param userId 用户id
     * @return
     */
    public List<Map<String, Object>> listHistory(String userId) {
        List<Map<String, Object>> list = iHistoryInfoDAO.listHistory(userId);
        return list;
    }

    /**
     * 删除历史记录
     * @param historyInfo
     */
    public void delete(HistoryInfoEntity historyInfo) {
        iHistoryInfoDAO.delete(historyInfo);
    }
}

